package com.pzh.assignment.common.bean.vo;

import com.pzh.assignment.common.bean.GlobalConstant;
import com.pzh.assignment.entity.College;
import lombok.Data;

import java.time.format.DateTimeFormatter;


@Data
public class CollegeVO {
    private Integer id;

    private String name;

    private String createTime;

    private String updateTime;

    public static CollegeVO valueOf(College college) {
        CollegeVO vo = new CollegeVO();
        vo.setId(college.getId());
        vo.setName(college.getName());
        if (college.getCreateTime() != null) {
            vo.setCreateTime(college.getCreateTime().format(DateTimeFormatter.ofPattern(GlobalConstant.DATE_FORMAT_PATTERN)));
        }
        if (college.getUpdateTime() != null) {
            vo.setUpdateTime(college.getUpdateTime().format(DateTimeFormatter.ofPattern(GlobalConstant.DATE_FORMAT_PATTERN)));
        }
        return vo;
    }
}
